﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace WindowsFormsApplication1.model
{
    

    class model
    {

        SqlConnection s = new SqlConnection(@"Data Source=VAIO\SQLEXPRESS;Initial Catalog=WindowsFormsApplication1.model;Integrated Security=True");
        SqlCommand sqlcmd;

        public bool addorUpdate(string quary)
        {
            try
            {
                s.Open();
                sqlcmd = new SqlCommand(quary, s);
                sqlcmd.ExecuteNonQuery();

                s.Close();

            }
            catch (Exception ex)
            {
                return false;
            }

            return true;

        }

        public SqlDataReader getresult(string quary)
        {
            try
            {
                s.Open();
                sqlcmd = new SqlCommand(quary, s);
                SqlDataReader queryFromDataBase = sqlcmd.ExecuteReader();
                

                s.Close();
                return queryFromDataBase;

            }
            catch (Exception ex)
            {
                throw ex;
            }

            

        }
    }
}
